<?php
class Default_Model_TourLocation extends Zend_Db_Table{

	protected $_name = TOUR_LOCATION_TABLE;
	protected $_primary = 'tour_location_id';

	private $TOUR_LOCATION_ID = 'tour_location_id';
	private $TOUR_ID = 'tour_id';
	private $LOCATION_ID = "location_id";

	protected $db;

	public function __construct(){
		//Goi ket noi voi Zend Db
		$this->db = Zend_Registry::get('connectDB');
	}

	protected $_messageError = null;

	public function getLocationByTourId($tourId) {
		$select = $this->db->select()->from(TOUR_LOCATION_TABLE)->where($this->TOUR_ID.' = ?',$tourId);
		$result  = $this->db->fetchAll($select);
		return $result;
	}

	// Xoa thong tin tour location
	public function deleteTourLocationByTourId($tourId){
		try {
			$this->db->delete(TOUR_LOCATION_TABLE,$this->TOUR_ID.' = ' . $tourId);
			return true;
		} catch (Exception $e) {
			$this->_messageError = $e->getMessage();
			return false;
		}
	}
	public function deleteTourLocationByLocId($locId){
		try {
			$this->db->delete(TOUR_LOCATION_TABLE,$this->LOCATION_ID.' = ' . $locId);
			return true;
		} catch (Exception $e) {
			$this->_messageError = $e->getMessage();
			return false;
		}
	}

	public function getError(){
		return $this->_messageError;
	}
}